// 列表头按钮配置
import {deleteFile, getDict} from "@/api/common";
import {getCurrentWarehouseCode} from "@/api/inbound/mesInTask";
import {getPrintTypeList} from "@/api/cabinet/cabinetPrint";
import {getSkillsCertificationList} from "@/api/employee/mesUserExtend";
import store from "@/store";
import url from "@/axios/url";
export const formConfig = {
  inline: true,
  formDesc: {
    warehouseCode: {
      type: "select",
      label: '仓库',
      prop: {
        value: "modelingCode",
        text: "modelingName",
      },
      options: async (data) => {
        const list = await getCurrentWarehouseCode();
        return list.data.result;
      },
    },
    itemName: {
      type: "input",
      label: '物料编号/名称',
    },
    itemType: {
      type: "select",
      label: '物料类型',
      prop: {
        value: "value",
        text: "text",
      },
      options: [
        {
          value: "1",
          text: "集采/辅料"
        },
        {
          value: "2",
          text: "车型/品质件"
        },
      ],
    },
    itemVin: {
      type: "input",
      label: 'VIN',
    },
    itemBrand: {
      type: "input",
      label: '品牌',
    },
    itemUnit: {
      type: "input",
      label: '规格',
    },
  }
}
export const operateList = [
  {
    name: "新增需求",
    type: "primary",
    icon: "el-icon-circle-plus-outline",
    handleName: "add", // 点击时返回的标识
  },
];
// 行末按钮配置
export const rowConfig = [
  // {
  //   name: $i18n.t("common.edit"),
  //   type: "primary",
  //   class: "row-btn-primary",
  //   handleName: "edit", // 点击时返回的标识
  // },
  // {
  //   name: $i18n.t("common.delete"),
  //   type: "danger",
  //   class: "row-btn-danger",
  //   handleName: "delete", // 点击时返回的标识
  // },
];
// 搜索条件配置
export const searchConfig = {
  data() {
    const self = this;
    return {
      searchDialog: {
        inline: true,
        formDesc: {
          warehouseCode: {
            type: "select",
            label: '仓库',
            prop: {
              value: "modelingCode",
              text: "modelingName",
            },
            options: async (data) => {
              const list = await getCurrentWarehouseCode();
              return list.data.result;
            },
          },
          itemCode: {
            type: "input",
            label: '物料编号/名称',
          },
          itemType: {
            type: "select",
            label: '物料类型',
            prop: {
              value: "value",
              text: "text",
            },
            options: [
              {
                value: "1",
                text: "集采/辅料"
              },
              {
                value: "2",
                text: "车型/品质件"
              },
            ],
          },
          itemVin: {
            type: "input",
            label: 'VIN',
          },
          itemBrand: {
            type: "input",
            label: '品牌',
          },
          itemUnit: {
            type: "input",
            label: '规格',
          },
        },
      },
    };
  },
};
const { adminUrl } = url();
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,

  formDesc: {
    materialName: {
      type: "input",
      label: '物料',
      layout: 24,
      required: true
    },
    // itemUnit: {
    //   layout: 24,
    //   type: "select",
    //   label: '单位',
    //   prop: {
    //     text: "description",
    //     value: "value"
    //   },
    //   attrs: {
    //     disabled:true,
    //     placeholder:'请选择物料'
    //   },
    //   // Promise 对象
    //   options: async (data) => {
    //     const list = await getDict("material_unit")
    //     return list.data.result
    //   }
    // },
    materialBrand: {
      type: 'input',
      label: '品牌',
      layout: 24,
      required: true
    },
    materialUnit: {
      type: "input",
      layout: 24,
      label: '规格',
      required: true
    },
    supplierId: {
      type: "input",
      layout: 24,
      label: '供应商',
      required: true
    },
    materialNum: {
      type: 'number',
      label: '订货数量',
      layout: 24,
      required: true,
      attrs: {
        min: 0,
      },
    },
    materialPackNum: {
      type: 'number',
      label: '总量',
      layout: 24,
      required: true,
      attrs: {
        min: 0,
      },
    },
    materialPhotoUrl: {
      type: "image-uploader",
      label: "物料照片",
      layout: 24,
      required: false,
      attrs: {
        fileSize: 3, // 文件大小限制 单位M
        // fileType: ["png"],
        multiple: true, // 是否支持多选
        // disabled: true,
        size: 80, // 图片显示大小
        action: `${adminUrl}file`,
        data: {
          bucket: "messervice",
        },
        headers: {
          Satoken: store.getters.token,
        },
        beforeRemove: (data, list) => {
          const bucket = "messervice";
          const filename = data.title;

          return new Promise((resolve, reject) => {
            deleteFile(`${adminUrl}file`, {
              bucket,
              filename,
            })
              .then((res) => {
                resolve(res.data);
              })
              .catch((error) => {
                reject(error);
              });
          });
        },
        responseFn(response, file) {
          return {
            src: response.result.path,
            // title: response.result.object,
            ...response.result,
          };
        },
      },
    },
  }
}
export const formDescDialogSpIn = {
  span: 24,

  formDesc: {
    materialName: {
      type: "input",
      label: '物料',
      layout: 24,
      required: true
    },
    itdPackType: {
      type: "input",
      label: '入库方式',
      layout: 24,
      required: true
    },
    materialBrand: {
      type: 'input',
      label: '品牌',
      layout: 24,
      required: true
    },
    materialUnit: {
      type: "input",
      layout: 24,
      label: '规格',
      required: true
    },
    supplierId: {
      type: "input",
      layout: 24,
      label: '供应商',
      required: true
    },
    materialNum: {
      type: 'number',
      label: '入库数量',
      layout: 24,
      required: true,
      attrs: {
        min: 0,
      },
    },
    materialPackNum: {
      type: 'number',
      label: '总量',
      layout: 24,
      required: true,
      attrs: {
        min: 0,
      },
    },
  }
}
export const formDescDialogSpOut = {
  span: 24,

  formDesc: {
    itemName: {
      type: "input",
      label: '物料',
      layout: 24,
      attrs: { readonly: true },
      required: true
    },
    itemBrand: {
      type: 'input',
      label: '品牌',
      layout: 24,
      attrs: { readonly: true },
      //required: true
    },
    itemUnit: {
      type: "input",
      layout: 24,
      label: '规格',
      attrs: { readonly: true },
      //required: true
    },
    itemSupName: {
      type: "input",
      layout: 24,
      label: '供应商',
      attrs: { readonly: true },
      //required: true
    },
    outUnit: {
      type: "input",
      layout: 24,
      label: '出库单位',
      required: true
    },
    materialNum: {
      type: 'number',
      label: '出库数量',
      layout: 24,
      required: true,
      attrs: {
        min: 0,
      },
    },
    materialPackNum: {
    type: "number",
    label: '出库总数',
    layout: 24,
    attrs: {
      min: 0,
    },
    },
  }
}
